#!/bin/bash
case $# in
    1) 
        img="$1";;
    2)
        img="$1:$2";;
    *)
        echo "Usage: <command> [<image name>:<image tag>]"
        exit -1
esac
echo "Run image ${img}..."

hostDir="${HOME}/docker_home"
user="1172"
group="502"
clientHome="${HOME}"

echo run docker image ${img}

docker run \
    --shm-size 32G \
    --net host \
    --rm \
    -u ${user}:${group}\
    -v ${HOME}/sys/etc/group:/etc/group:ro \
    -v /etc/passwd:/etc/passwd:ro \
    -v /etc/shadow:/etc/shadow:ro \
    -v ${hostDir}:${clientHome} \
    -v ${HOME}/bin:${clientHome}/bin \
    -v ${HOME}/caffe-quants-3.8:${clientHome}/caffe-quants-3.8 \
    -v ${HOME}/tmp:${clientHome}/tmp \
    -v ${HOME}/onnx-quants-3.8:${clientHome}/onnx-quants-3.8 \
    -v ${HOME}/autotest:${clientHome}/autotest \
    -w ${clientHome} \
    -it \
    ${img}
